<template>
  <div class="h5-wrapper">
    <div class="content">
      <!-- 二级路由出口：专门用来显示匹配的Layout二级路由组件内容 -->
      <keep-alive>
        <RouterView />
      </keep-alive>
    </div>
    <nav class="tabbar">
      <RouterLink to="/article">面经</RouterLink>
      <RouterLink to="/collect">收藏</RouterLink>
      <RouterLink to="/like">喜欢</RouterLink>
      <RouterLink to="/user">我的</RouterLink>
    </nav>
  </div>
</template>

<script>
export default {
  // 这个名字选项是不是就有作用了？可以在 keep-alive 的时候使用
  name: 'LayoutPage',
  beforeCreate () {
    console.log('beforeCreate')
  },
  created () {
    console.log('created - 如果在Layout的created中也要发个请求呢？')
  },
  beforeMount () {
    console.log('beforeMount')
  },
  mounted () {
    console.log('mounted')
  },
  destroyed () {
    console.log('Layout页面销毁了...')
  },

  // 缓存的组件被激活时，触发，页面进入时
  activated () {
    console.log('activated')
  },
  // 缓存的组件失活时，触发，页面离开时
  deactivated () {
    console.log('deactivated')
  }
}
</script>

<style>
body {
  margin: 0;
  padding: 0;
}
</style>
<style lang="less" scoped>
.h5-wrapper {
  .content {
    margin-bottom: 51px;
  }
  .tabbar {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: center;
    display: flex;
    background: #fff;
    border-top: 1px solid #e4e4e4;
    a {
      flex: 1;
      text-decoration: none;
      font-size: 14px;
      color: #333;
      -webkit-tap-highlight-color: transparent;
      // & => 当前选择器
      &.router-link-active {
        color: orange;
      }
    }

    // a.router-link-active {
    //   color: orange;
    // }
  }
}
</style>
